/**
 * @summary 文章请求模块
 */
import req from '@/utils/request';
import * as URL from '@/constants/api';

/**
 * @param { string } articleId
 * @returns
 * @summary 获取文章评论列表
 */
export function getArticleCommentList(articleId) {
  return req({
    url: URL.COMMENT_LIST,
    params: {
      type: 'a',
      source: articleId,
    },
  })
    .then(res => res.data.data)
    .catch(() => null);
}

export function addComment(params) {
  return req({
    url: URL.COMMENT_LIST,
    method: 'POST',
    data: params,
  })
    .then(res => res.data)
    .catch(err => Promise.reject(err.response.data.message));
}
